package mucontrol;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import mudbconnection.DBUsers;
import muobject.User;

@Component("LoginControlService")
public class LoginControlService implements LoginControl {
	
	@Autowired
	private DBUsers DBUsersService;

	public boolean checkTeacherLogin(String account, String password, String type){
		try{
			User loginUser = DBUsersService.getLoginUser(account, password);
			if (loginUser != null){
				if (type.equals("T")){
					switch(loginUser.getTypeNo()){
					case 1:
						return true;
					case 2:
						return true;
					case 3:
						return false;
					}
				}
				if (type.equals("S")){
					switch(loginUser.getTypeNo()){
					case 1:
						return true;
					case 2:
						return true;
					case 3:
						return true;
					}
				}
			}
		return false;
		}catch(Exception e){
			return false;
		}
	}
	
}
